package main

import (
	"fmt"
	"math"
	"strings"
)

func lengthOfLongestSubstring(s string) int {
	return method1(s)
}

func method1(s string) int {
	n := len(s)
	if n < 2 {
		return n
	}

	length := math.MinInt
	left , right := 0, 1
	
	for right < n {
		if !strings.ContainsRune(s[left:right], rune(s[right])) {
			right += 1
		} else {
			if length < right - left {
				length = right - left
			}
			left += 1
		}
	}
	if length < n - left {
		length = n - left
	}
	return length
}

func main() {
	fmt.Println(method1("abcabcbb"))
	fmt.Println(method1("bbbbb"))
	fmt.Println(method1("pwwkew"))
}